__author__ = 'zhenjiao.su'
# -*- coding: utf-8 -*-
from selenium import webdriver
from Confing import confing
from Saveorder import saveorder
from Payserver import payserver
from Shouye import shouye
from List import list
from Detail import detail
import Other
from time import sleep
alw=webdriver.Chrome()
alw.get("http://fh.dujia.qunar.com/?tf=package")
alw.maximize_window()
<<<<<<< HEAD
shouyes=shouye(alw)
if shouyes.shouyeexit()==True:
    print(u"进入首页成功")
    shouyes.b2ccitypeople()
    shouyes.b2cclick()
else:
    print(u"进入首页失败")
    raise SystemError
searchs=list(alw)
handl1=alw.current_window_handle
if searchs.listpageexit()==True:
    if searchs.searchloadingexit()==False:
        if searchs.searchexit()==True:
            print(u"存在搜索结果")
            searchs.searchresults()
            print(searchs.sumprice)
            print(searchs.aveprice)
            print(searchs.gohotel)
            raise SystemError
=======
def testcase1(driver):
    shouyes=shouye(driver)   #首页
    if shouyes.shouyeexit()==True:
        shouyes.b2ccitypeople(choose=1)
        shouyes.b2cclick()
    else:
        print(u"进入首页异常")
        raise SystemError
    lists=list(driver)    #list页
    if lists.listpageexit()==True:
        if lists.searchloadingexit()==False:
            if lists.searchexit()==True:
                handle1=driver.current_window_handle
                lists.searchclick()
            else:
                print(u"搜索没有结果")
                raise SystemError
>>>>>>> d05ae885d823964ce31b210a988fe79c22c83a49
        else:
            print(u"搜索存在异常")
            raise SystemError
    else:
        print(u"进入list页失败")
        raise SystemError
<<<<<<< HEAD
else:
    print(u"进入搜索页失败")
    raise SystemError
handls=alw.window_handles
alw.close()
for handl2 in handls:
    if handl2 !=handl1:
        alw.switch_to_window(handl2)
details=detail(alw)
if details.overexit("detailpageover")==True:
    print(u"detail售卖完")
    raise SystemError
if details.detailpageexit()==False:
    print(u"进入detail页失败")
    raise SystemError
else:
    print(u"进入detail成功")
sleep(10)
if details.overexit("flightexit")==True or details.overexit("hotelexit")==True or details.overexit("detailpageover")==True:
    print(u"实时接口返回卖完")
    raise SystemError
details.detailattribute()
details.detailroomsearch()
detailroomname=details.roomname
detailsumpay=details.detailsumpre
detailhotelname=details.detailhotelname
details.detailclick()
if details.detailloadexit()==False:
    print(u"detail提交失败")
    raise SystemError
elif details.detailloadexit() =="warning":
    print(u"提交异常")
    raise SystemError
if details.overexit("detailpageover")==True:
    print(u"detail提交失败，产品卖完")
    raise SystemError
confings=confing(alw)
if confings.confingexit()==True:
    confings.peopletrval()
    confings.messagepeople()
    if confings.confingloading(timeout=50)==True:
        pass
=======
    Other.browser(driver,handle1)
    details=detail(driver)    #detail页
    if details.overexit(pageexitnumber=3)==False:
        if details.detailpageexit()==True:
            sleep(10)
            if details.overexit(pageexitnumber=1)==True:
                print(u"机票卖完")
                raise SystemError
            if details.overexit(pageexitnumber=2)==True:
                print(u"酒店卖完")
                raise SystemError
            if details.overexit(pageexitnumber=3)==True:
                print(u"全卖完")
                raise SystemError
            details.detailroomsearch()
            details.detailattribute()
            details.detailclick()
            if details.detailloadexit()==True:
                print(u"离开了detail页")
            else:
                print(u"detail提交异常")
                raise SystemError
        else:
            print(u"进入detail页失败")
            raise SystemError
>>>>>>> d05ae885d823964ce31b210a988fe79c22c83a49
    else:
        print(u"进入detail失败，提示卖完")
        raise SystemError
    confings=confing(driver)   #configme页
    handle1=driver.current_window_handle
    if details.overexit(pageexitnumber=3)==True:
        print(u"detail进入confirm页失败，提示卖完")
        raise SystemError
    if confings.confingexit()==True:
        confings.peopletrval()
        confings.messagepeople()
        confings.messagesubmit()
        if confings.confingloading()==True:
            print(u"离开了confirm页")
        elif confings.confingloading()==False:
            print(u"提交失败")
            raise SystemError
        else:
            print(u"提交loading超时")
            raise SystemError
    saveorders=saveorder(driver)
    if saveorders.saveorderexit()==True:
        saveorders.saveordersults()
        print(saveorders.savepayorder)
        saveorders.saveorderpayclick()
        if saveorders.saveorderloading()==False:
            if saveorders.savepaychangeexit()==True:
                print(u"有变价提示")
                saveorders.savepaychange()
            if details.overexit(pageexitnumber=3)==True:
                print(u"saveover提示卖完")
                raise SystemError
            if saveorders.saveorderstate()==True:
                print(u"支付中心反回成功")
                Other.browser(driver,handle1)
        else:
            print(u"提交异常")
            raise SystemError
    else:
        print(u"进入saveorder失败")








